﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace TSCC.DataAccess
{
    public class Utility:DA_Matrix
    {
        public DataTable GetUserInfo(string p_id)
        {
            string sql = getUserInfoStatement();
            setCommand(sql);
            IDbDataParameter para = cmd.CreateParameter();
            para.DbType = DbType.String;
            para.Value = p_id;
            cmd.Parameters.Add(para);
            return getData(cmd);
        }

        protected string getUserInfoStatement()
        {
            return @"SELECT 
                                CSREmployee.姓名
                                , CSREmployee.組別
                                , CSREmployee.員編
                                , Manager.PW
                           FROM CSREmployee LEFT OUTER JOIN Manager ON CSREmployee.員編 = Manager.員編
                           WHERE 1=1 AND 
                            CSREmployee.員編=?;";
        }

        public DataTable GetTeam()
        {
            string sql = getTeamStatement();
            return getData(sql, "TEAM");
        }

        protected string getTeamStatement()
        {
            return @"SELECT 
                        DISTINCT CSREmployee.組別
                    FROM CSREmployee";
        }
    }
}
